﻿using Microsoft.Practices.Prism.Commands;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using HDFSViewer.Component;
using HDFSViewer.Model;

namespace HDFSViewer.ViewModel
{
    public class ConnectHDInsightWindowVM : NotifyObject
    {
        private string _userName = "hadoop";
        public string UserName
        {
            get { return _userName; }
            set
            {
                _userName = value;
                OK.RaiseCanExecuteChanged();
                this.RaisePropertyChanged("UserName");
            }
        }

        private string _account = "";
        public string Account
        {
            get { return _account; }
            set
            {
                _account = value;
                OK.RaiseCanExecuteChanged();
                this.RaisePropertyChanged("Account");
            }
        }

        private string _key = "";
        public string Key
        {
            get { return _key; }
            set
            {
                _key = value;
                OK.RaiseCanExecuteChanged();
                this.RaisePropertyChanged("Key");
            }
        }

        private string _containerName = "default";
        public string ContainerName
        {
            get { return _containerName; }
            set
            {
                _containerName = value;
                OK.RaiseCanExecuteChanged();
                this.RaisePropertyChanged("ContainerName");
            }
        }

        public bool AutoCreateContainer{get;set;}

        public DelegateCommand OK { get; set; }

        public ConnectHDInsightWindowVM()
        {
            AutoCreateContainer = true;
            OK = new DelegateCommand(DoOK, DoCanOK);
        }

        private void DoOK() { }

        private bool DoCanOK()
        {
            return !string.IsNullOrWhiteSpace(UserName) && !string.IsNullOrWhiteSpace(Account) && !string.IsNullOrWhiteSpace(Key) && !string.IsNullOrWhiteSpace(ContainerName);
        }
    }
}
